package com.baizhi.controller;

import com.baizhi.entity.Admin;
import com.baizhi.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by 小荷~ on 2019/6/16.
 */

@Controller
public class AdminController {

    @Autowired
    private AdminService service;


    @RequestMapping("selectOne")
    public String selectOne(String userName, String passWord, HttpSession session){

        System.out.println("******username*******"+userName+"++++++++++++password++++++++"+passWord);

        Admin admin = service.selectOne(userName,passWord);

        if(admin != null){

            session.setAttribute("admin",admin);

            return "main/main";

        }else {

            return "login";

        }

    }

    @RequestMapping("tuichu")
    public String tuichu(HttpSession session){

        session.removeAttribute("admin");

        System.out.println("清楚session");

        return "login";

    }

}
